package mx.edu.ittoluca.fp;

import javax.swing.*;
import java.awt.*;

import static javax.swing.JFrame.EXIT_ON_CLOSE;

/**
 * Created with IntelliJ IDEA.
 * User: Victor Santillán
 * Date: 25/06/12
 * Time: 10:27 PM
 */
public class ControlCircle1 extends JFrame{

    public ControlCircle1(){
        JPanel panel = new JPanel();
        JButton jbtEnlarge = new JButton("Enlarge");
        panel.add(jbtEnlarge);
        JButton jbtShrink = new JButton("Shrink");
        panel.add(jbtShrink);
        CirclePanel canvas = new CirclePanel();
        this.add(canvas, BorderLayout.CENTER);
        this.add(panel, BorderLayout.SOUTH);
    }

    public static void main(String[] args){
        JFrame frame = new ControlCircle1();
        frame.setTitle("ControlCircle1");
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(200, 200);
        frame.setVisible(true);
    }

    class CirclePanel extends JPanel{
        private int radius = 5;

        @Override
        protected void paintComponent(Graphics g){
            super.paintComponent(g);
            g.drawOval(getWidth() / 2 - radius, getHeight() / 2 - radius, 2 * radius, 2 * radius);
        }
    }
}
